# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=python-distutils-extra
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-distutils-extra" "${MINGW_PACKAGE_PREFIX}-python2-distutils-extra")
pkgver=2.39
pkgrel=3
pkgdesc="Enhancements to the Python build system (mingw-w64)"
arch=('any')
license=('GPL')
url="https://launchpad.net/python-distutils-extra"
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools" "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=("https://launchpad.net/${_realname}/trunk/$pkgver/+download/${_realname}-$pkgver.tar.gz"
        "https://launchpad.net/${_realname}/trunk/$pkgver/+download/${_realname}-$pkgver.tar.gz.asc")
validpgpkeys=("3DB46B55EFA59D40E6232148D14EF15DAFE11347") # Martin Pitt <martinpitt@gnome.org>
sha256sums=('723f24f4d65fc8d99b33a002fbbb3771d4cc9d664c97085bf37f3997ae8063af'
            'SKIP')

prepare() {
  cd "$srcdir"/
  for pver in {2,3}; do 
    rm -rf python${pver}-build-${CARCH}| true
    cp -r "${_realname}-${pkgver}" "python${pver}-build-${CARCH}"
  done
}

build() {  
  for pver in {2,3}; do  
    msg "Python ${pver} build for ${CARCH}"  
    cd "${srcdir}/python${pver}-build-${CARCH}"
    MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python${pver} setup.py build
  done  
}
check() {  
  for pver in {2,3}; do  
    msg "Python ${pver} test for ${CARCH}"  
    cd "${srcdir}/python${pver}-build-${CARCH}"
    MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python${pver} setup.py test
  done  
}

package_python3-distutils-extra() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3>=3.3" "intltool")

  cd "${srcdir}/python3-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix="${MINGW_PREFIX}" --root="${pkgdir}" --skip-build
}

package_python2-distutils-extra() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2>=2.7" "intltool")

  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix="${MINGW_PREFIX}" --root="${pkgdir}" --skip-build
}


# Wrappers
package_mingw-w64-i686-python2-distutils-extra() {
  package_python2-distutils-extra
}

package_mingw-w64-i686-python3-distutils-extra() {
  package_python3-distutils-extra
}

package_mingw-w64-x86_64-python2-distutils-extra() {
  package_python2-distutils-extra
}

package_mingw-w64-x86_64-python3-distutils-extra() {
  package_python3-distutils-extra
}

